from Crypto.Cipher import DES
from Crypto.Util.Padding import pad, unpad
import base64

def des_encrypt(text, key):
    key = key.encode('utf-8')
    cipher = DES.new(key, DES.MODE_ECB)
    text_bytes = text.encode('utf-8')
    padded_text = pad(text_bytes, DES.block_size)
    encrypted_bytes = cipher.encrypt(padded_text)
    encrypted_text = base64.b64encode(encrypted_bytes).decode('utf-8')
    return encrypted_text

def des_decrypt(text, key):
    key = key.encode('utf-8')
    cipher = DES.new(key, DES.MODE_ECB)
    encrypted_bytes = base64.b64decode(text)
    decrypted_bytes = cipher.decrypt(encrypted_bytes)
    unpadded_bytes = unpad(decrypted_bytes, DES.block_size)
    decrypted_text = unpadded_bytes.decode('utf-8')
    return decrypted_text
    